<?php

/**
 * Adding an Update
 * @package ModuleAssistance
 * @version 1.0b
 */

session_start();

// Configuration file
include '../configuration.php';
// Functions
include '../inc/functions.php';

// Checking if user is logged in
if (!CheckSession()):
	exit();
endif;

// Include all objects
// TODO: Include only needed classes
foreach (glob($configuration['webroot'].'objects/*.php') as $class) { include_once $class; }

try {
	// Creating update
	$update = new Update();
	$update->supportcaseId = $_POST['supportcase'];
	$update->content = $_POST['content'];
	$update->crmuserId = $_POST['owner'];
	$update->date = date('Y-m-d H:i');
	
	// Inserting update into database
	$update->SaveNew();
	
	echo 'OK';

} catch (Exception $e) {
	echo $e->getMessage();
}
?>